package com.linchong.concurrency.chapter10.v1;

import java.util.Collection;

/**
 * @BelongsProject:concurrency_1
 * @BelongsPackage:com.linchong.concurrency.chapter10
 * @Author:linchong
 * @CreateTime:2020-07-28 08:49
 * @Description: 定义一个接口方法，存放锁公共的部分
 */
public interface Lock {

 class TimeOutException extends Exception{
 	public TimeOutException(String message){
 		super(message);
    }
 }

	/**
	 * 加锁
	 * @throws InterruptedException
	 */
	void lock() throws InterruptedException;

	/**
	 * 超时释放锁
	 * @param mills
	 * @throws InterruptedException
	 */
	void lock(long mills) throws InterruptedException, TimeOutException;

	/**
	 * 释放锁
	 */
	void unlock();

	/**
	 * 获取阻塞的锁
	 * @return
	 */
	Collection<Thread> getBlockedThread();

	/**
	 * 获取阻塞锁的数量
	 * @return
	 */
	int getBlockedSize();



}
